Table of Contents
Previous setup
We already have srtm_1arc_v3.tif raster on the postgis_raster database, in the rasters.dem table. The import was done using:
raster2pgsql -s 3763 -N -32767 -t 100x100 -I -C -M -d srtm_1arc_v3.tif rasters.dem | psql -d postgis_raster -h localhost -U geobox -p 5432
Install GeoServer PGRaster community module
We will need the GeoServer PGRaster community module. Download and install the version for your current GeoServer installation.cd /var/lib/tomcat7/webapps/geoserver/WEB-INF/lib
sudo unzip ~/Transferências/geoserver-2.10-SNAPSHOT-pgraster-plugin.zip
Configure ImageMosaicJDBC store
Step 1: configuration files
We need some configuration files for the ImageMosaicJDBC plugin. Put these files in ourGEOSERVER_DATA_DIR/data.
File connect.pgraster.xml.inc
<connect>
<dstype value="DBCP"/>
<username value="geobox"/>
<password value="geobox"/>
<jdbcUrl value="jdbc:postgresql://localhost:5432/postgis_raster"/>
<driverClassName value="org.postgresql.Driver"/>
<maxActive value="10"/>
<maxIdle value="0"/>
</connect>
mapping.pgraster.xml.inc
<spatialExtension name="pgraster"/>
<mapping>
<masterTable name="mosaic" >
<coverageNameAttribute name="name"/>
<maxXAttribute name="maxX"/>
<maxYAttribute name="maxY"/>
<minXAttribute name="minX"/>
<minYAttribute name="minY"/>
<resXAttribute name="resX"/>
<resYAttribute name="resY"/>
<tileTableNameAtribute name="tiletable" />
</masterTable>
<tileTable>
<blobAttributeName name="rast" />
</tileTable>
</mapping>
mosaicpgraster.pgraster.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE ImageMosaicJDBCConfig [
<!ENTITY mapping PUBLIC "mapping" "mapping.pgraster.xml.inc">
<!ENTITY connect PUBLIC "connect" "connect.pgraster.xml.inc">
]>
<config version="1.0">
<coverageName name="oek"/>
<coordsys name="EPSG:3763"/>
<scaleop interpolation="1"/>
<axisOrder ignore="false"/>
&mapping;
&connect;
</config>
Step 2: Supporting tables and data
We need one additional table on ourpostgis_raster database to store simple mosaic metadata.
CREATE TABLE public.mosaic (
name character varying(254) COLLATE pg_catalog."default" NOT NULL,
tiletable character varying(254) COLLATE pg_catalog."default" NOT NULL,
minx double precision,
miny double precision,
maxx double precision,
maxy double precision,
resx double precision,
resy double precision,
CONSTRAINT mosaic_pkey PRIMARY KEY (name, tiletable)
);
mosaic metadata table, assigning the name mosaicpgraster:
insert into mosaic (name,tiletable) values ('mosaicpgraster','rasters.dem');
Step 3: Create a new datastore
Create a newImageMosaicJDBC store.
For the URL, use the file we created: file:data/mosaicpgraster.pgraster.xml.
Save it.
Step 4: Create a new layer from the store
Step 5: Preview the layer
https://github.com/lcalisto/workshop-postgis-raster/blob/master/doc/geoserver.md]]>